import {ReqGetBaseCategoryList,ReqGetFloor,ReqGetSlide} from "@/api"

const state = {
    categoryList:[],  //三级分类数据
    slide:[],  //首页轮播图数据
    floor:[]   //首页楼层数据
}

const mutations = {
    SAVE_CATEGORY_LIST(state,value){
        state.categoryList = value.slice(0,15);
    },
    SAVE_SLIDE_LIST(state,value){
        state.slide = value
    },
    SAVE_FLOOR_LIST(state,value){
        state.floor = value;
    }
}

const actions = {
    async GetCategoryList({commit}){
        let data = await ReqGetBaseCategoryList()
        // console.log(data)
        commit("SAVE_CATEGORY_LIST",data)
    },
    // 请求首页 轮播图 数据
    async GetSlide({commit}){
        let data = await ReqGetSlide()
        // console.log(data)
        commit("SAVE_SLIDE_LIST",data)
    },
    // 请求首页 楼层 数据
    async GetFloorList({commit}){
        let data = await ReqGetFloor();
        // console.log(data)
        commit("SAVE_FLOOR_LIST",data);
    }
}

const getters = {

}

export default {
    namespaced:true,
    state,
    mutations,
    actions,
    getters
}